Assignemnt #61 and 59th program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 59th Program
///File name: Fift9Prog.java
///Date Finished:11/12/2015
import java.util.Scanner;
import java.util.Random;
public class Fift9Prog
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int x = 1 + r.nextInt(10);
System.out.println( "I have chosen a number between 1 and 10. try to guess it." );
System.out.print( "Your guess: " );
int entry = keyboard.nextInt();
System.out.println( "" );
while ( entry != x )
{
System.out.println( "\nSorry, That's wrong. try again. ");
System.out.print( "> " );
entry = keyboard.nextInt();
}
System.out.println( "" );
System.out.println( "Great job. You got it." );
}
}
Picture of the output